/*================================================================
 *   Copyright (C) 2021 www.hsby.link All rights reserved.
 *
 *   文件名称：test_iomanager.cc
 *   创 建 者：汉森伯逸
 *   创建日期：2021/5/3
 *   描    述：
 *
 *================================================================*/

#include <iostream>
#include <memory>
#include <thread>
#include <time.h>
using namespace std;

#include "log.h"

void testHSBY_LOG_ROOT(){
    HSBY_LOG_DEBUG(HSBY_LOG_ROOT()) << "test HSBY_LOG_ROOT";
}

void testLoggerMgr(){
    auto l = hsby::LoggerManagerSgt::Instance().getLogger("xx");
    l->addAppender(make_shared<hsby::FileLogAppender>("log.txt"));
}

void testFileAppender(){

    hsby::Logger::Ptr logger(new hsby::Logger("testLogger"));
    hsby::FileLogAppender::Ptr file_appender(new hsby::FileLogAppender("log.txt"));
    file_appender->setFormatter(make_shared<hsby::LogFormatter>("%d{%Y-%m-%d %X}[%p]%T%m%n{nnnn}"));
    file_appender->setLevel(hsby::LogLevel::DEBUG);
    logger->Log(hsby::LogLevel::DEBUG, std::make_shared<hsby::LogEvent>(logger, hsby::LogLevel::DEBUG, __FILE__, __LINE__, 0,
                                                                        hsby::GetThisThreadId(), hsby::GetThisThreadName(), hsby::GetThisFiberIntId(),
                                                                        time(0)));

    HSBY_LOG_ERROR(HSBY_LOG_ROOT()) << "test FileAppender";
}

void testLOG_FMT(){
//    HSBY_LOG_FMT_DEBUG(HSBY_LOG_ROOT(), "This is debug fmt %s", "test LOG_FMT");
}

int main(){
    testHSBY_LOG_ROOT();
    return 0;
}